[gitlab] Add PRComment classes and GitLab support for bot: help command#376
Merged
trz42 merged 18 commits intoJun 16, 2026
Merged
Conversation
'notable' should be 'noteable'
Some docstrings already referred to subclasses of BaseEventInfo as EventInfo without EventInfo actually being defined anywhere
Commands might for example be supported on GitHub, but not GitLab. Responding with a message explicitly stating that the command is unsupported is more useful to the user than letting the command handler run until it fails.
trz42
requested changes
Jun 9, 2026
- Inherit from `ABC` and make methods abstract - Improve docstring and comments - Improve `body` XOR `id` check - Ensure `id` is not an empty string - Use `ValueError`s - Add arguments to `edit` and `append` Co-authored-by: Thomas Röblitz <trz42@users.noreply.github.com>
Co-authored-by: Thomas Röblitz <trz42@users.noreply.github.com>
sondrebr
commented
Jun 10, 2026
| if not self.body: | ||
| raise Exception("'body' must be set to create a comment.") | ||
| if self.id: | ||
| # Safeguard: id should not be set when body is initialized, but guard |
Collaborator
Author
There was a problem hiding this comment.
😝
Edit: Hound noticed the missing indentation
`_require_body` and `_require_id` for checking if respectively `self.body` and `self.id` are set. Co-authored-by: Thomas Röblitz <trz42@users.noreply.github.com>
Apply suggestions to use `_require_body` and `_require_id` Co-authored-by: Thomas Röblitz <trz42@users.noreply.github.com>
trz42
reviewed
Jun 11, 2026
trz42
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me! I'll give it another try against GitLab and also check if it works on GitHub, and merge it then.
Contributor
Tested PR against both GitLab and GitHub with all supported commands. All good. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Another step in implementing GitLab support for the bot, most notably making it support the
bot: helpcommand. Changes include:tools/pr_comments.py:PRCommentclass renamed toPRCommentInfoBasePRCommentclass, "interface" to implement for each Git hosting platform to support creating/getting/editing PR commentsGitHubPRCommentclass, GitHub implementation ofBasePRCommentGitLabPRCommentclass, GitLab implementation ofBasePRCommentcreate_pr_comment_instance()function creating an instance of the correctPRCommentclasscreate_comment()function to use thePRCommentclassestools/commands.py:ALL_COMMANDSconstant (list containing all existing bot commands)SUPPORTED_COMMANDS_PER_GIT_HOSTconstant (dictionary listing supported/implemented commands per Git hosting platform)get_supported_commands()function retrieving the supported commands for the configured Git hosting platformeessi_bot_event_handler.py:handle_issue_comment_event()method to use the EventInfo properties andget_app_name()handle_note_event = handle_issue_comment_eventto make the bot process GitLab commentshandle_bot_command()method to check if command is supported on the configured Git hosting platformbot: helpresponse message to include a list of unsupported commands (if any)get_app_name()totools/git.pyto get the app/bot name (separate settings for GitHub/GitLab)notable_typeinstead ofnoteable_type🤦)Usage
To use the bot in its current state on GitLab, follow the Usage section in the description of #370, except:
514bdf6...is installed.apiscope and the Reporter role (not Planner!) for the bot to be able to post comments.GITLAB_WEBHOOK_SECRET_TOKENenvironment variable. Make sure to include thewhsec_prefix.whsec_. These can be generated e.g. by runningpython -c "import base64, secrets; print('whsec_' + base64.b64encode(secrets.token_bytes(32)).decode())".